package com.yellowpage.client.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.client.data.NspUserPerson;
import com.yellowpage.client.dao.NspUserPersonDao;

public class NspUserPersonServiceImpl extends BaseServiceImpl implements NspUserPersonService {
	  private NspUserPersonDao nspUserPersonDao;
	
	  public void setNspUserPersonDao(NspUserPersonDao nspUserPersonDao) {
		  this.nspUserPersonDao = nspUserPersonDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public NspUserPerson getNspUserPerson(Long id){
	      return nspUserPersonDao.get(id);
	  }
	  
    public List<NspUserPerson> getAllNspUserPerson(){
        return nspUserPersonDao.getAll();
    }
    
    public List<Map> queryNspUserPersonByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.MOBILENO , a.COMADDR , a.COMUSER , a.COMTEL , a.ZIPCODE , a.MERCHATID , a.ATTENTIONSTOCK , " +
				"a.ATTENTIONTIME , a.CANCELTIME , a.ATTENTIONPRICE , a.CLASSSEQUENCE , a.SUBMITTER , a.SUBMITTIME , a.UPDATEUSER , a.UPDATETIME , a.ID , a.DESCRIPTION    FROM NSP_USER_PERSON a WHERE 1=1 ")
				    			.addCondition(" and MOBILENO = :mobileNo ")
							    			.addCondition(" and COMADDR = :comAddr ")
							    			.addCondition(" and COMUSER = :comUser ")
							    			.addCondition(" and COMTEL = :comtel ")
							    			.addCondition(" and ZIPCODE = :zipcode ")
							    			.addCondition(" and MERCHATID = :merchatId ")
							    			.addCondition(" and ATTENTIONSTOCK = :attentionStock ")
							    			.addCondition(" and date_format(ATTENTIONTIME,'%Y-%m-%d') = :attentionTime ")
							    			.addCondition(" and date_format(CANCELTIME,'%Y-%m-%d') = :cancelTime ")
							    			.addCondition(" and ATTENTIONPRICE = :attentionPrice ")
							    			.addCondition(" and CLASSSEQUENCE = :classSequence ")
							    			.addCondition(" and SUBMITTER = :submitter ")
							    			.addCondition(" and date_format(SUBMITTIME,'%Y-%m-%d') = :submitTime ")
							    			.addCondition(" and UPDATEUSER = :updateUser ")
							    			.addCondition(" and date_format(UPDATETIME,'%Y-%m-%d') = :updateTime ")
							    			.addCondition(" and ID = :id ")
							    			.addCondition(" and DESCRIPTION = :description ")
							    ; 		    
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveNspUserPerson(NspUserPerson nspUserPerson){
        nspUserPersonDao.save(nspUserPerson);
    }
    
	  public void updateNspUserPerson(NspUserPerson nspUserPerson){
	      nspUserPersonDao.update(nspUserPerson);
	  }
	  
	  public void delete(List deleteList){
	      nspUserPersonDao.remove(deleteList);
	  }
	  
	  
	 
	
}	